<!DOCTYPE html>
<html>
<head>
<title>编辑广告</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>编辑广告</h5>
            </div>
           <form id="inputForm" action="update" method="post">
           		<input type="hidden" name="id" value="#(ad.id)">
	            <div class="ibox-content">
	                <div class="form-horizontal clearfix">
	                    <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="name" value="#(ad.name)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">广告位：</label>
                            <div class="col-sm-3">
                                <select class="form-control" name="adPositionId">
                                    <option value="">--请选择--</option>
                                    #for(adPosition : adPositions)
                                        <option value="#(adPosition.id)" #if(ad.adPositionId==adPosition.id) selected #end>#(adPosition.name)</option>
                                    #end
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">内容：</label>
                            <div class="col-sm-8">
                               <textarea id="introduction" name="introduction" class="ibox-content no-padding" style="height: 250px;">#(ad.introduction)</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片：</label>
                            <div class="col-sm-3">
                                <input type="text" id="image" name="image" class="form-control" value="#(ad.image)"/>
                            </div>
                            <div class="col-sm-3">
                                <a href="javascript:;" id="filePicker" class="btn btn-primary">选择文件</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">链接地址：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="url" value="#(ad.url)">
                            </div>
                        </div>
	                </div>
	            </div>
	            <div class="modal-footer col-sm-3 col-sm-offset-2">
	                <button type="submit" class="btn btn-w-m btn-primary">确定</button>
	                <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
	            </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
    var $introduction = $("#introduction");
    var $image = $("#image");
    var $filePicker = $("#filePicker");
    
    
    
    $filePicker.uploader();
    
    $introduction.editor();
    
    // 表单验证
    $inputForm.validate({
        rules: {
            name: "required",
            adPositionId:"required"
        }
    });

});
</script>
